import { Controller, Get, Post, Body, Param, Delete, Put, Query } from '@nestjs/common';
import { Platform_Service } from './platform.service';
import { Platform_Create_Dto, Platform_Update_Dto } from './assets/platform.dto';
import { Platform_Find_Dto } from './assets/platform.dto';
import { ApiExtraModels, ApiTags } from '@nestjs/swagger';
import { util_ApiResponse_Base } from '@/common/util/apiResponse';
import { util_Index_ReturnContent } from '@/common/util/index';
import { Class_Index_ListAll } from '@/common/classes/index';

@Controller('/adm/platform')
@ApiTags('platform 商品')
export class Platform_Controller {
  constructor(private readonly platform_Service: Platform_Service) {}

  @Post('/add')
  @util_ApiResponse_Base({
    dataType: 'dataType_add',
    //apiKey: '/adm/platform/add Post',
  })
  async platform_Create(@Body() body: Platform_Create_Dto) {
    return util_Index_ReturnContent(await this.platform_Service.platform_Create(body));
  }

  @Get('/list')
  @util_ApiResponse_Base({
    dataType: 'dataType_list',
    //apiKey: '/adm/platform/list Get',
  })
  async platform_FindByPage(@Query() query: Platform_Find_Dto) {
    return util_Index_ReturnContent(await this.platform_Service.platform_FindByPage(query));
  }

  @Get('/listSelect')
  @ApiExtraModels(Class_Index_ListAll)
  @util_ApiResponse_Base({
    dataType: 'dataType_listSelect',
    type: Class_Index_ListAll,
  })
  async platform_FindAllSelect() {
    return util_Index_ReturnContent(await this.platform_Service.platform_FindAllSelect());
  }

  @Get('/platformSelect')
  @util_ApiResponse_Base({
    dataType: 'dataType_listSelect',
    type: Class_Index_ListAll,
  })
  async platform_FindAndProduct() {
    return util_Index_ReturnContent(await this.platform_Service.platform_FindAndProduct());
  }

  @Get('/detail/:id')
  @util_ApiResponse_Base({
    dataType: 'dataType_ell',
    //apiKey: '/adm/platform/detail/:id Get',
  })
  async platform_FindOneById(@Param('id') id: string) {
    return util_Index_ReturnContent(await this.platform_Service.platform_FindOneById(+id));
  }

  @Put('/update')
  @util_ApiResponse_Base({
    dataType: 'dataType_update',
    //apiKey: '/adm/platform/update Put',
  })
  async platform_Update(@Body() body: Platform_Update_Dto) {
    return util_Index_ReturnContent(await this.platform_Service.platform_Update(body));
  }

  @Delete('/delete/:id')
  @util_ApiResponse_Base({
    dataType: 'dataType_delete',
    //apiKey: '/adm/platform/delete/:id Delete',
  })
  async platform_Remove(@Param('id') id: string) {
    return util_Index_ReturnContent(await this.platform_Service.platform_Remove(+id));
  }
}
